<?php

namespace app\api\controller;

use app\admin\model\article\Article;
use app\common\controller\Backend;
use app\common\model\ads\Ads;
use app\common\model\ads\Position;
use app\common\model\Car;
use app\common\model\Staff;

class Index extends Backend
{
    protected array $noNeedLogin = ['index'];
    protected array $noNeedPermission = ['overview'];

    public function initialize(): void
    {
        parent::initialize();
    }

    public function overview(): void
    {
        $static = [
            "income_day" => 0,
            "income_month" => 0,
            "free_car_num" => 0,
            "staff_num" => 0
        ];

        $static["income_day"] = \app\common\model\Order::whereDay('create_time')->sum('amount');
        $static["income_month"] = \app\common\model\Order::whereMonth('create_time')->sum('amount');
        $static["free_car_num"] = Car::where(['status' => 1])->count("*");
        $static["staff_num"] = Staff::where(['status' => 1])->count("*");

        $this->success('', $static);
    }
}